﻿@using System.Globalization
@using System.Threading
@using EveKillboard.Core.Views
@model IEnumerable<EveKillboard.Core.Views.TopView>
           
<div id="topkillerscontent" style="border-left: 1px #323232 solid; border-right: 1px #323232 solid; border-bottom: 1px #323232 solid; padding-bottom: 5px;">
    <div class="topKillersLabel gradientheader">@if (Model.First() is IMonthView && Model.First() is IKillsView ){
          @string.Format(Thread.CurrentThread.CurrentCulture, EveKillboard.Content.Labels.month_top_killers, DateTime.Today.ToString("MMMM"))
       }else if (Model.First() is IWeekView && Model.First() is IKillsView){
          @string.Format(Thread.CurrentThread.CurrentCulture, EveKillboard.Content.Labels.week_top_killers, 
          CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(
                DateTime.UtcNow.Date,
                CultureInfo.InvariantCulture.DateTimeFormat.CalendarWeekRule,
                CultureInfo.InvariantCulture.DateTimeFormat.FirstDayOfWeek)) 
       }else if (Model.First() is IMonthView && Model.First() is IValueView){
           @string.Format(Thread.CurrentThread.CurrentCulture, EveKillboard.Content.Labels.month_top_killers_value, DateTime.Today.ToString("MMMM"))}</div>
    <div style="width: 140px; margin-left: auto; margin-right: auto">
        <img src="../../Content/themes/base/images/topkiller_64.png" width="64px" height="64px" style="border: 0px; margin-top: 6px; margin-bottom: 6px;" alt=""/>
        <img src="@string.Format("http://image.eveonline.com/Character/{0}_64.jpg", Model.First().EveId)" width="64px" height="64px" title="@string.Format("{0}", Model.First().Name)" style="border: 0px;margin-top: 6px; margin-bottom: 6px;" alt="">
    </div>
    @{
        var max = Model.First() is IKillsView ? Model.First().Count : Model.First().Value;
    }
    @foreach (var killer in Model) {
        <div style="padding-left: 3px; padding-right: 3px;">
            <div><a class="evelink" href="@string.Format("pilot/{0}", killer.InternalId)">@killer.Name</a></div>
            <div class="backgroundbar"><div class="innerbar" style="@string.Format(CultureInfo.InvariantCulture, "width:{0:n0}%;", (killer is IKillsView ? killer.Count : killer.Value) / max * 100)"></div></div>
            <div style="text-align:right;display: inline-block;margin-left: 5px;">@if (killer is IKillsView){ @string.Format(CultureInfo.InvariantCulture, "{0}", killer.Count) }else { @string.Format(EveKillboard.Core.EveCustomFormatProvider.Instance, "{0}", killer.Value) }</div>
        </div>
    }
</div>